﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12泛型类与接口
{
    class Program
    {
        static void Main(string[] args)
        {
            //泛型类定义对象
            //GenericClass<int> genericInt = new GenericClass<int>();
            //genericInt._T = 1;

            //GenericClass<string> genericString = new GenericClass<string>();
            //genericString._T = "你好";

            //泛型类定义对象
            GenericArrayClass<int> intArray = new GenericArrayClass<int>(5);  
            Random random = new Random();
            //设置元素值
            for(int i = 0; i < 5; i++)
            {
                intArray.SetItem(i, random.Next(0,10));
            }
            //取出元素值
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("原值是:{0}", intArray.GetItem(i));
            }
            //调用排序方法
            intArray.Sort(1);
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("排序后的值是:{0}", intArray.GetItem(i));
            }

        }
    }
}
